import { resolve } from 'path'
import { defineConfig, externalizeDepsPlugin } from 'electron-vite'
import vue from '@vitejs/plugin-vue'
import Components from 'unplugin-vue-components/vite';
import { AntDesignVueResolver } from 'unplugin-vue-components/resolvers';
import {fileURLToPath, URL} from 'node:url'

export default defineConfig({
  main: {
    plugins: [externalizeDepsPlugin()]
  },
  preload: {
    plugins: [externalizeDepsPlugin()]
  },
  renderer: {
    resolve: {
      alias: {
        '@': fileURLToPath(new URL('src/renderer/src', import.meta.url)),
        '@renderer': resolve('src/renderer/src')
      }
    },
    plugins: [
      vue(),
      Components({
        resolvers: [
          AntDesignVueResolver({
            importStyle: false, // css in js
          }),
        ]
      })
    ],
    server:{
      host: '127.0.0.1',
      port: 5173,
      proxy: {
        '/abusapp': {
          target: 'http://112.124.35.236:8080/', //目标服务器地址
          changeOrigin: true,
          // rewrite: (path) => path.replace(/^\/api/, '')
          // rewrite: (path) => path.replace('/api', '')
        }
      }
    },
    envDir: resolve(__dirname,"src/env")

  }
})
